# -*- coding:utf-8 -*-
import tornado.web
from toTest.commons import mod_Pager


INFO_LIST = [
	{'tit':'foo_tit','con':'foo_con'}
]
for i in range(300):
	temp = {'tit':'这是标题'+str(i),
			'con':'这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容'+str(i)}
	INFO_LIST.append(temp)

class IndexHandler(tornado.web.RequestHandler):
	def get(self, page):  # page为url中的参数，即用户访问时的参数
		page_obj = mod_Pager.Pagination(page, len(INFO_LIST), 3)
		current_list = INFO_LIST[page_obj.start:page_obj.end]  # 内容显示数量
		num_page = page_obj.page_num('/index/')  # 当前显示的页码数字链接
		self.render("home/index.html",info_list=current_list,current_page=page_obj.current_page,num_page=num_page)

	def post(self, page):
		tit = self.get_argument('tit')
		con = self.get_argument('con')
		temp = {'tit':tit,'con':con}
		INFO_LIST.append(temp)
		self.redirect('/index/'+page)